#include"../mqserver/mq_queue.hpp"
#include<gtest/gtest.h>
mq::MsgQueueManager::ptr msgqptr;


using tmpmap = std::unordered_map<std::string,std::string>;
class MsgQueuetest : public testing::Environment{
    public:
        virtual void SetUp(){
            msgqptr = std::make_shared<mq::MsgQueueManager>("./a/db_file");
        }
        virtual void TearDown(){
            // msgqptr->clear();
        }
};

// TEST(queue_test,insert_test){
//         tmpmap _tmap = {{"k1","v1"},{"k2","v2"}};
//         msgqptr->declare("queue1",true,false,false,tmpmap());
//         msgqptr->declare("queue2",true,false,false,_tmap);
//         msgqptr->declare("queue3",true,false,false,_tmap);
//         msgqptr->declare("queue4",true,false,false,tmpmap());

// }

// TEST(queue_test,select_test){
//     ASSERT_EQ(msgqptr->exists("queue1"),true);
//     ASSERT_EQ(msgqptr->exists("queue4"),true);
//     ASSERT_EQ(msgqptr->exists("queue2"),true);

//     ASSERT_EQ(msgqptr->size(),4);
//     mq::MsgQueue::ptr it = msgqptr->select("queue1");
//     ASSERT_EQ(it->name,"queue1");
//     ASSERT_EQ(it->durable,true);
//     ASSERT_EQ(it->exclusive,false);
//     ASSERT_EQ(it->auto_delete,false);
//     ASSERT_EQ(it->getargsstr(),std::string(""));

//     mq::MsgQueue::ptr it3 = msgqptr->select("queue3");
//     ASSERT_EQ(it3->name,"queue3");
//     ASSERT_EQ(it3->durable,true);
//     ASSERT_EQ(it3->exclusive,false);
//     ASSERT_EQ(it3->auto_delete,false);
//     // ASSERT_EQ(it3->getargsstr(),std::string("k1=v1&k2=v2&"));
// }

// TEST(exchange_test,remove_test)
// {
//     msgqptr->deleteMsgQueue("queue2");
//     mq::MsgQueue::ptr msgqtmp = msgqptr->select("queue2");
//     ASSERT_EQ(msgqtmp.get(),nullptr);
//     ASSERT_EQ(msgqptr->exists("queue2"),false);

//     msgqptr->deleteMsgQueue("queue4");
//     mq::MsgQueue::ptr msgqtmp4 = msgqptr->select("queue4");
//     ASSERT_EQ(msgqtmp4.get(),nullptr);
//     ASSERT_EQ(msgqptr->exists("queue4"),false);

//     ASSERT_EQ(msgqptr->size(),2);
// }   

int main(int argc,char* argv[]){
    testing::InitGoogleTest(&argc,argv);
    testing::AddGlobalTestEnvironment(new MsgQueuetest);
    return RUN_ALL_TESTS();
}

